<template>
    <div>
        <h1>添加会员等级</h1>
<table class="table table-bordered" border="1">
<tr>
    <td>会员等级名称</td>
    <td><input type="text" placeholder="请输入会员等级名称" v-model="tj.rank_name"></td>
</tr>

<tr>
    <td>会员等级状态</td>
    <td><input type="radio" :value="true" v-model="tj.rank_zt" checked>启用
        <input type="radio" v-model="tj.rank_zt"  :value="false">禁用</td>
</tr>

<tr>
    <td>最小成长值</td>
    <td><input type="text" placeholder="请输入最小成长值" v-model="tj.rank_min"></td>
</tr>

<tr>
    <td>最大成长值</td>
    <td><input type="text" placeholder="请输入最大成长值" v-model="tj.rank_max"></td>
</tr>

<tr>
    <td></td>
    <td><input type="button" value="添加" @click="pd"></td>
</tr>
</table>
    </div>
</template>

<script setup lang="ts">
import axios from "axios";
import { ref } from "vue";

const tj=ref({


rank_id: 0,
  rank_name: "",
  rank_zt: true,
  rank_min: 0,
  rank_max: 0

})

const pd=()=>{

if(tj.value.rank_name=="")
{

alert('会员等级名称不能为空');
return;
}

if(tj.value.rank_min<0||tj.value.rank_max>99)
{

    alert('最小值不能小于0且最大值不能大于99');
    return;
}

axios.post('https://localhost:7268/api/hy/addmemberanke',tj.value)
.then(res=>{

if(res.data==-1)
{
    alert('该会员等级已经被注册');
    return;

}
if(res.data>0)
{

alert('注册成功');

}
else{
    alert('注册失败');

}



})
.catch(error=>{

console.log(error)

})
}


</script>

<style scoped>

</style>